<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <canvas id="container" width="300" height="300"></canvas>
  <script>
    // 方式一
    function draw() {
      var canvas = document.getElementById('container');
      if (!canvas.getContext) return;
      var ctx = canvas.getContext("2d");
      ctx.beginPath();
      ctx.arc(50, 50, 40, 0, 2 * Math.PI, false);
      ctx.stroke();
    }
    draw();
    // 方式二
    function demo() {
      var canvas = document.getElementById('container');
      if (!canvas.getContext) return;
      var ctx = canvas.getContext("2d");
      ctx.beginPath()
      ctx.moveTo(50, 50);
      ctx.arcTo(200, 50, 200, 200, 100);
      ctx.stroke()

      ctx.beginPath();
      ctx.rect(50, 50, 3, 3);
      ctx.rect(200, 50, 3, 3)
      ctx.rect(200, 200, 3, 3)
      ctx.fill()
    }
    demo()
  </script>
</body>

</html>